<?php 

class RecipeCategory extends AppModel{

	public $name = 'RecipeCategory';
	
	
	public $belongsTo = array(		'ParentCategory' => array(
										'className' => 'RecipeCategory',
										'foreignKey' => 'parent_id'
									),
								
								);
	
	public $hasMany = array(	'ChildCategory' => array(
										'className' => 'RecipeCategory',
										'foreignKey' => 'parent_id'
									)
								);
	
	public $hasAndBelongsToMany = array(	'Recipe' => array(
												'className' => 'Recipe',
												'joinTable' => 'recipes_recipe_categories',
												'foreignKey' => 'category_id',
												'associationForeignKey' => 'recipe_id'
											)
								);


	public $validate = array(
		'title' => array(
			'required' => array(
				'rule' => 'notEmpty',
				'message' => 'The title is required.',
				),
			'minLength' => array(
				'rule' => array('minLength', 4),
				'message' => 'Minimum 8 characters long.',
				),
			'isUnique' => array(
				'rule' => 'isUnique',
				'message' => 'This title has already been taken.',
				),
			),
		'parent_id' => array(
			'required' => array(
				'rule' => 'notEmpty',
				'message' => 'The parent category is required.'
				),
			'numeric' => array(
				'rule' => 'numeric',
				'message' => 'Please supply the number.'
				),
			),

		);

}
?>